package com.ponhu.ea2.stockcenter.dto;

import com.ponhu.ea2.common.basic.model.BaseCriteria;
import com.ponhu.ea2.stockcenter.enums.ExchangeActionTypeEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.ObjectUtils;

import java.io.Serializable;
import java.util.Arrays;
import java.util.List;

@Data
@Accessors(chain = true)
public class StockBatchChangeQueryDTO extends BaseCriteria implements Serializable {

    @ApiModelProperty(value = "批次编码")
    private String batchCode;

    @ApiModelProperty(value = "货品编码")
    private String inventoryCode;

    @ApiModelProperty(value = "变动类型：true-入库，false-出库")
    private Boolean inOut;

    @ApiModelProperty(value = "变动类型Code集合")
    private List<Integer> actionCodes;

    @ApiModelProperty(value = "关联单据类型Code")
    private Integer actionType;

    @ApiModelProperty(value = "关联业务单号")
    private String directSn;

    public List<Integer> getActionCodes() {
        if (ObjectUtils.isNotEmpty(actionType))
            return Arrays.asList(actionType);
        if (ObjectUtils.isNotEmpty(inOut))
            return ExchangeActionTypeEnum.getInOutCodes(inOut);
        return null;
    }

}
